from stacking import *
from stacking.units import *

GENERATE_METHOD = "simulator"
SEED = 0
NITEMS = 1000
NSTACKS = 50

# create some producers and consumers to create items via simulation
products  = ["A"]
producers = [Producer.create_gg(products, 20*M, 5*M, 1, 0)]
consumers = [Consumer.create_xgg(products, *args) for args in
             [(2*D, 7*D, 1*D, 30, 5), 
              (1*D, 3*D, 6*H, 10, 2), 
              (12*H, 1*D, 2*H, 5, 1)]]
simulator = Simulator(producers, consumers)

# generate items for the instance
if GENERATE_METHOD == "generator":
    i = generator.generate(NITEMS, seed=SEED)
elif GENERATE_METHOD == "simulator":
    _, i = simulator.generate(NITEMS, seed=SEED)
else:
    raise ValueError("invalid generation method %r" % GENERATE_METHOD)

# quick-build warehouse
w = Warehouse.quick_build("foo", nstacks=NSTACKS)

# assemble instance
I = Instance(i, w)

# solve it using FO
s = solvers.HeuristicSolver(solvers.heuristics.FO)
s.driver.init(I, seed=0, verbose=True)
s.driver.run()
print s.solution.meta


